<template>
	<view>
		<!-- 商品列表 -->
		<view class="detail-desc">
		<!-- 	<view class="d-header">
				<text>商品列表</text>
			</view> -->
			<view v-for="(item,i) in data" :key="i" class="item" style="width: 95%;margin: 0 2.5%;margin-top: 20upx;">
				<!-- @click="jumpgoods" :data-id='item.id' -->
				<image class="triangle" :src="item.goods_thumb" mode="widthFix" style="border-radius: 20upx;border: 1upx solid #DDDDDD;box-shadow: 1upx 1upx 10upx #DDDDDD;" @click="jumpgoods(item.id)"></image>
				<view class="detail">
					<view class="name" style="color: #000000;font-weight: 555;font-size: 30upx;height: 47upx;">{{item.goods_desc}}</view>
					<view class="webkit" style="position: relative;height: 30upx;">
						<text style="font-size: 24upx;color: #aaaaaa;font-weight: 550;" class="flex"> {{item.goods_name}} </text>
						<view style="position: absolute;top: -10upx;right: 20upx;">
							<text style="color: #aaaaaa;padding: 0 5upx;">|</text><text style="font-weight: 555;font-size: 34upx;">￥{{item.cost_price}}</text><text>/</text><text style="text-decoration: line-through;color: #aaaaaa;font-size: 22upx;">{{item.level_price}}</text>
						</view>
					</view>
				</view>
			</view>
		</view>
		
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				data:[],
				user_id:'',
				res:[],
			}
		},
		onLoad(){
			uni.getStorage({
				key: 'user_id',
				success: (res) => {
				  this.user_id = res.data
					this.loadData();
				},
			});
		},
		methods: {
			loadData(){
				// 商品列表
				let o = this
				uni.request({
				    url: 'https://cx.mingmeijt.com/Api/Goods/index',
						method: 'POST',
						data:{
							user_id: this.user_id
						},
						header:{'Content-Type':'form-data'},
				    success: (res) => {
							this.data = res.data.data.list
							for(var i=0; i<o.data.length; i++) {
								o.data[i].goods_detail = 'https://cx.mingmeijt.com' + o.data[i].goods_detail
							}
							for(var i=0; i<o.data.length; i++) {
								o.data[i].goods_thumb = 'https://cx.mingmeijt.com' + o.data[i].goods_thumb
							}
							console.log(this.data)
						}
				});
			},
			jumpgoods(orderid){
				uni.navigateTo({
					url: '/pages/product/product?goodsid=' + orderid
				})
			},
		}
	}
</script>

<style lang='scss'>
	.detail-desc{
		background: #fff;
		margin-top: 16upx;
		.d-header{
			display: flex;
			justify-content: center;
			align-items: center;
			height: 80upx;
			font-size: $font-base + 2upx;
			color: $font-color-dark;
			position: relative;
				
			text{
				padding: 0 20upx;
				background: #fff;
				position: relative;
				z-index: 1;
			}
			&:after{
				position: absolute;
				left: 50%;
				top: 50%;
				transform: translateX(-50%);
				width: 300upx;
				height: 0;
				content: '';
				border-bottom: 1px solid #ccc;
			}
		}
	}
	
	.triangle {
		width: 100%;
		height: 350upx;
		/* height: 666upx; */
		display: block;
	}
	.detail {
		background: #fff;
		padding: 20upx 12upx;
	}
	.name {
		height: 68upx;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
		font-size: 24upx;
		line-height: 36upx;
	}
	.item {
		width: 100%;
		padding: 10upx;
		box-sizing: border-box;
	}
</style>
